<template>
    <div v-if="showExerciseFrame">
      <the-exercise-frame :questions="questions" :myindex="index" :lastime="lastime" :workType="workType"/>
    </div>
</template>
<script>
import TheExerciseFrame from './commons/TheExerciseFrame'

export default{
  components: {
    TheExerciseFrame
  },
  data () {
    return {
      showExerciseFrame: true,
      index: 0,
      lastime: 0,
      questions: [],
      workType: 0
    }
  },
  mounted () {
    // 获取路由来的工种代码
    if (this.$route.params.workid !== undefined) {
      var workTypeId = this.$route.params.workid
    }
    console.log('继续未完成的题目,工种代码为:' + workTypeId)
          // 开启过渡效果
    this.$vux.loading.show({text: '请稍候!'})
          // 准备题目、练习进度和时间
    var questionArray = JSON.parse(localStorage.getItem(workTypeId))
    var i = 0
    while (questionArray[i].checkedOption.length === 1) {
      i++
      // console.log(i)
    }
    var lastMins = localStorage.getItem(workTypeId + '-lastMins')
    // 向做题界面子组件传递参数
    this.index = i
    this.lastime = lastMins
    this.questions = questionArray
    this.workType = workTypeId
    // 显示做题界面
    this.showExerciseFrame = true
    // 隐藏提示界面
    // this.showPrepareExercise = false
    this.$vux.loading.hide()
  }
}
</script>
<style>

</style>
